package com.yidu.ruifeng_logistics.service.impl;

import com.yidu.ruifeng_logistics.entity.LogisticsCourier;
import com.yidu.ruifeng_logistics.dao.LogisticsCourierDao;
import com.yidu.ruifeng_logistics.service.LogisticsCourierService;
import com.yidu.ruifeng_logistics.vo.CourierVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 快递员表(LogisticsCourier)表服务实现类
 *
 * @author makejava
 * @since 2021-03-18 15:43:29
 */
@Service("logisticsCourierService")
public class LogisticsCourierServiceImpl implements LogisticsCourierService {
    @Resource
    private LogisticsCourierDao logisticsCourierDao;

    @Override
    public LogisticsCourier selectStaffById(Integer staffId) {
        return logisticsCourierDao.selectStaffById(staffId);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param courierId 主键
     * @return 实例对象
     */
    @Override
    public LogisticsCourier queryById(Integer courierId) {
        return this.logisticsCourierDao.queryById(courierId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<LogisticsCourier> queryAllByLimit(int offset, int limit) {
        return this.logisticsCourierDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param logisticsCourier 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsCourier insert(LogisticsCourier logisticsCourier) {
        this.logisticsCourierDao.insert(logisticsCourier);
        return logisticsCourier;
    }

    /**
     * 修改数据
     *
     * @param logisticsCourier 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsCourier update(LogisticsCourier logisticsCourier) {
        this.logisticsCourierDao.update(logisticsCourier);
        return this.queryById(logisticsCourier.getCourierId());
    }

    /**
     * 通过主键删除数据
     *
     * @param courierId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer courierId) {
        return this.logisticsCourierDao.deleteById(courierId) > 0;
    }

    @Override
    public List<CourierVo> queryAll(CourierVo logisticsCourier) {
        return this.logisticsCourierDao.queryAll(logisticsCourier);
    }

    @Override
    public int deleteAll(String ids) {
        String[] s= ids.split(",");
        return logisticsCourierDao.deleteAll(s);
    }

}
